package com.hunttown.mes.rpc.domain.enums.mes.produce;

import java.util.HashMap;
import java.util.Map;

/**
 * 订单状态：0新订单/1审核中/5已审核/10备料中/12生产中/15已暂停/20已完工/26测试中/28待发货/30已发货/35已完成/40已归档
 * created by wangjunfu on 2019/08/19
 */
public enum OrderStatusEnum {
    RECALL(-10, "撤回"),
    REJECT(-1, "驳回"),
    NEWORDER(0, "新订单"),
    APPROVING(1, "审核中"),
    APPROVE(5, "已审核"),
    REDAY(10, "备料中"),
    PRODUCE(12, "生产中"),
    PAUSE(15, "已暂停"),
    FINISH(20, "已完工"),
    TESTING(26, "测试中"),
    WAITSEND(28, "待发货"),
    SEND(30, "已发货"),
    COMPETE(35, "已完成"),
    FILE(40, "已归档");

    private final int key;
    private final String value;

    OrderStatusEnum(int key, String value) {
        this.key = key;
        this.value = value;
    }

    // 根据key获取枚举
    public static String getEnumByKey(int key) {
        String value = "";

        for (OrderStatusEnum temp : OrderStatusEnum.values()) {
            if (temp.getKey() == key) {
                value = temp.getValue();
            }
        }

        return value;
    }

    // 将枚举组成Map
    public static Map<Integer, String> getEnumList() {
        Map<Integer, String> map = new HashMap<>();

        for (OrderStatusEnum temp : OrderStatusEnum.values()) {
            map.put(temp.getKey(), temp.getValue());
        }

        return map;
    }

    public int getKey() {
        return key;
    }

    public String getValue() {
        return value;
    }
}
